<template>
	<view class="rtl" v-show="isShow">

		<view class="shopCartMenu" :style="$attrs.bgStyle">
			<view class="title">
				<view class="back" v-if="isBack" @click="BackBallback">
					<uv-icon name="arrow-left" size="18"></uv-icon>
					<view class="text">
						{{t("back")}}
					</view>
				</view>
				{{title}}
				<view class="reset" @click="ResetBallback">
					Reset
				</view>
			</view>
			<view class="content">
				<slot></slot>
			</view>
			<view class="footer">
				<view class="" @click="CancelBallback">
					{{t("Cancel")}}
				</view>
				<view class="Confrm" @click="ConfrmBallback">
					{{t("Confrm")}}<uv-icon name="arrow-right" color="#fff"></uv-icon>
				</view>
			</view>

		</view>
		<view class="shield"> </view>
	</view>
</template>

<script setup>
	import {
		ref,
		useAttrs,
		onMounted,
		defineExpose
	} from "vue"
	import {
		useI18n
	} from "vue-i18n";
	const {
		t
	} = useI18n()
	const $attrs = useAttrs();
	const title = ref("")
	const isShow = ref(false)
	const isBack = ref(false)

	onMounted(() => {
		if ($attrs.title) {
			title.value = $attrs.title
		}
	})
	const emit = defineEmits(["BackBallback", "ResetBallback", "CancelBallback", "ConfrmBallback"]);
	const BackBallback = () => {
		emit("BackBallback")
	}
	const ResetBallback = () => {
		emit("ResetBallback")
	}
	const CancelBallback = () => {
		isShow.value = false
		emit("CancelBallback")
	}
	const ConfrmBallback = () => {
		emit("ConfrmBallback")
	}
	defineExpose({
		title,
		isBack,
		isShow
	})
</script>

<style lang="scss" scoped>
	@import "@/static/css/index.scss";

	.shopCartMenu {
		position: fixed;
		z-index: 1;
		bottom: 0;
		left: 0;
		width: 100%;
		min-height: 40%;
		max-height: 60%;
		background: #fff;
		border-radius: 30rpx 30rpx 0 0;
		display: flex;
		flex-direction: column;

		.title {
			padding: 10rpx 20rpx;
			text-align: center;
			border-bottom: 1px solid #e9e9e9;
			position: relative;
			height: 60rpx;

			.back {
				position: absolute;
				left: 20rpx;
				top: 50%;
				transform: translateY(-50%);
				padding: 20rpx 50rpx 20rpx 0;
				display: flex;
				align-items: center;

				.text {
					padding-left: 10rpx;
				}
			}

			.reset {
				position: absolute;
				right: 20rpx;
				top: 50%;
				transform: translateY(-50%);
				padding: 20rpx 0rpx 20rpx 50rpx;
			}
		}

		.content {
			flex: 1;
			overflow-y: scroll;
			padding: 0 20rpx;
		}

		.footer {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 30rpx 40rpx;
			background: $primary-b;
			color: #fff;
			border-radius: 10rpx 10rpx 0 0;
			font-size: 28rpx;

			.Confrm {
				display: flex;
				align-items: center;
			}
		}
	}

	.shield {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		background: rgba(0, 0, 0, .5);
	}
</style>